import React, { Component } from "react";
export default class OmsRadio extends Component{
  constructor(props){
    super(props);
    this.handleChange = this.handleChange.bind(this);
    this.state = {
      radioValue:this.props.radioValue || ''
    }
  }
  handleChange(e){
    this.setState({
        radioValue:e.target.value
        }
    )
}
  loopHtmlFun(item){
    var tempStr = '',_this = this;
    tempStr = item.map((el, index) =>{
      return  <label className="oms-radio" key={index}>
                <input type={el.type}  checked={_this.state.radioValue===el.val} name={el.name}  value={el.val} onChange={this.handleChange} />{el.title}
             </label>
    })
    return tempStr;
  }
  render(){
    var _this = this,
        pageDate = _this.props.data;
      
    return(<React.Fragment>{_this.loopHtmlFun(pageDate)}</React.Fragment>
    );
  }
}